!function (t) {
    function i(s) {
        if (e[s]) return e[s].exports;
        var n = e[s] = {
            exports: {},
            id: s,
            loaded: !1
        };
        return t[s].call(n.exports, n, n.exports, i), n.loaded = !0, n.exports
    }
    var e = {};
    return i.m = t, i.c = e, i.p = "./", i(0)
}([function (t, i, e) {
    e(1), e(2), e(3), e(4)
},  function (t, i) {
    Vue.component("pop-customer-component", {
        template:'<div class="pop-panel" v-bind:class="{\'show\':this.show}"><div class="pop-box"><div class="pop-title">{{title}}<a class="win_close_btn" @click="close()"><i class="fa fa-fw fa-close"></i></a></div><div class="pop-content"><validator name="validatorMethod"><form role="form"><div class="box-body"><div class="form-group"><label for="organization_name">所属机构</label><input type="text" id="organization_name" v-model="customer.organization_name" class="form-control" @click="showTreeOrganization()" v-bind:value="customer.organization_name" @invalid="organizationNameInvalid" detect-change="off" detect-blur="off" initial="off" v-validate:organization_name="[\'required\']" readonly></div><div class="form-group"><label for="title">登录帐号</label><input type="text" id="name" v-model="customer.name" @invalid="nameInvalid" detect-change="off" detect-blur="off" initial="off" v-validate:name="[\'required\']" v-bind:value="customer.name" class="form-control"></div><div class="form-group" v-if="customer.id==0"><label for="title">登录密码</label><input type="password" id="password" v-model="customer.password" @invalid="passwordInvalid" detect-change="off" detect-blur="off" initial="off" v-validate:password="[\'required\']" v-bind:value="customer.password" class="form-control"></div><div class="form-group"><label for="color">客户姓名</label><input type="text" id="real_name" @invalid="realNameInvalid" detect-change="off" detect-blur="off" initial="off" v-model="customer.real_name" class="form-control" v-bind:value="customer.real_name" v-validate:real_name="[\'required\']"></div><div class="form-group"><label for="title">手机号码</label><input type="text" id="mobile_phone" v-model="customer.mobile_phone" @invalid="mobilePhoneInvalid" detect-change="off" detect-blur="off" initial="off" v-validate:mobile_phone="[\'required\']" v-bind:value="customer.mobile_phone" class="form-control"></div></div><div class="box-footer"><button type="button" class="btn btn-info btn-sm" style="width:120px;float:left;" @click="save()">保存</button><button type="button" class="btn  btn-default btn-sm" style="width:120px;float:left;margin-left:15px;" @click="close()">取消</button></div></form></validator></div></div><div class="bg"></div></div>',
        data: function () {
            return {
                show: !1,
                title:'提示窗口',
                showError:null,
                customer: {
                    id:0,
                    organization_id:0,
                    organization_name:'',
                    name:'',
                    password:'',
                    mobile_phone:'',
                    real_name:'',
                    level:0
                }
            }
        },
        events: {
            openCustomerWin: function (t) {
                var i = this;
                i.data_init(t);
            },
            selectOrg: function (t) {
                this.customer.organization_id = t.organization_id;
                this.customer.organization_name = t.organization_name;
            }
        },
        methods: {
            data_init: function (t) {
                this.title = t.title, this.customer = t.customer, this.showError = [], this.show = !0;
            },
            organizationNameInvalid: function () {
                var t = this;
                t.showError.push("请选择一个所属机构");
            },
            nameInvalid:function () {
                var t = this;
                t.showError.push("登录帐号不能为空");
            },
            passwordInvalid:function () {
                var t = this;
                t.showError.push("登录密码不能为空");
            },
            realNameInvalid:function() {
                var t = this;
                t.showError.push("客户姓名不能为空");
            },
            mobilePhoneInvalid:function() {
                var t = this;
                t.showError.push("手机号码不能为空");
            },
            showTreeOrganization:function () {
                var t = this;
                if (t.customer.setting !== undefined) {
                    if (t.customer.setting[5] == 1) {
                        t.$dispatch("openTreeOrganizationWin", {level:t.customer.level, organization_id:t.customer.organization_id});
                    }
                } else {
                    t.$dispatch("openTreeOrganizationWin", {level:t.customer.level, organization_id:t.customer.organization_id});
                }
            },
            save: function() {
                var t = this;
                t.$validate(true,function () {
                    if(!t.$validatorMethod.invalid) {
                        var index = layer.load(0, {shade:[0.3, '#000000']}); //0代表加载的风格，支持0-2
                        postMsg(root+"/customer/addoreditdata", t.customer, function(i) {
                            layer.close(index);
                            layer.alert(i.msg);
                            if (i.code == 0) {
                                t.show = !1;
                                if (t.customer.id == 0) {
                                    t.$dispatch("refreshCustomerList");
                                } else {
                                    t.$dispatch("refreshCustomerInfo", {customer:i.customer});
                                }
                            }
                        });
                    } else {
                        layer.alert(t.showError[(t.showError.length-1)], {end:function () {
                            t.showError = [];
                        }});
                    }
                });
            },
            close: function () {
                var t = this;
                t.show = !1;
            }
        }
    })
},  function (t, i) {
    Vue.component("pop-tree-organization-component", {
        template:'<div class="pop-panel" v-bind:class="{\'show\':this.show}"><div class="pop-box"><div class="pop-title">{{title}}<a class="win_close_btn" @click="close()"><i class="fa fa-fw fa-close"></i></a></div><div class="pop-content"><div style="height:435px;width:40%;border:1px solid rgba(0, 158, 203, 0.16);overflow-y:scroll;overflow-x:auto;float:left;"><ul id="treeDemo" class="ztree"></ul></div><div style="float:left;width:60%"><validator name="validatorMethod"><form role="form"><div class="box-body"><div class="form-group"><label for="p_name">上级机构</label><input type="text" id="p_name" v-model="organization.p_name" class="form-control" v-bind:value="organization.p_name" @invalid="pNameInvalid" detect-change="off" detect-blur="off" initial="off" v-validate:p_name="[\'required\']" readonly></div><div class="form-group"><label for="code">机构编码</label><span style="position:absolute;margin-top:32px;margin-left:-43px;">{{organization.p_code}}{{organization.level}}</span><input type="text" maxlength="4" minlength="4" id="code" v-model="organization.code" class="form-control" style="padding-left:46px;" v-bind:value="organization.code" @invalid="codeInvalid" detect-change="off" detect-blur="off" initial="off" v-validate:code="{required:true, minlength:4}"></div><div class="form-group"><label for="color">机构名称</label><input type="text" @invalid="nameInvalid" detect-change="off" detect-blur="off" initial="off" v-model="organization.name" class="form-control" v-bind:value="organization.name" v-validate:name="[\'required\']"></div><div class="form-group"><label for="title">手机号码</label><input type="text" v-model="organization.mobile_phone" v-bind:value="organization.mobile_phone" class="form-control"></div><div class="form-group"><label for="title">固定电话</label><input type="text" v-model="organization.phone" v-bind:value="organization.phone" class="form-control"></div></div><div class="box-footer"><button type="button" class="btn btn-info btn-sm" style="width:120px;float:left;" @click="save()"  v-bind:disabled="isSaveDisabled">{{btn_txt}}</button></div></form></validator></div><div class="box-footer"><button type="button" class="btn btn-info btn-sm" @click="selectOrg()" style="width:120px;float:left;" v-bind:disabled="isDisabled">{{button}}</button><button type="button" class="btn  btn-default btn-sm" style="width:120px;float:left;margin-left:15px;" @click="close()">取消</button></div></div></div><div class="bg"></div></div>',
        data: function () {
            return {
                show: !1,
                title:'提示窗口',
                button:'确认选择',
                btn_txt:'保存',
                isSaveDisabled:0,
                isDisabled:0,
                showError:null,
                getLevel:0,
                select:null,
                organization_id:0,
                organization: {
                    id:0,
                    p_name:"",
                    p_code:"0000",
                    p_level:0,
                    pid:-1,
                    code:"",
                    level:0,
                    name:"",
                    mobile_phone:"",
                    phone:"",
                    state:1
                }
            }
        },
        events: {
            'openTreeOrganizationWin': function (t) {
                var i = this;
                i.data_init(t);
            },
        },
        methods: {
            pNameInvalid:function () {
                var t = this;
                t.showError.push("请选择一个上级机构");
            },
            codeInvalid:function () {
                var t = this;
                t.showError.push("请填写八位数的机构编码");
            },
            nameInvalid:function () {
                var t = this;
                t.showError.push("请填写机构名称");
            },
            data_init: function (t) {
                this.title = t.title, this.getLevel = t.level, this.organization_id = t.organization_id, this.showError = [], this.show = !0;
                this.getTree();
            },
            getTree:function () {
                var t = this;
                postMsg(root+"/organization/tree", {level:t.getLevel, organization_id:t.organization_id}, function(i) {
                    var setting = {
                        callback:{
                            onClick:function (event, treeId, treeNode, clickFlag) {
                                if (clickFlag == 0 || treeNode.isAdd == 0) {
                                    t.select = null;
                                    t.isDisabled = 0;
                                    t.isSaveDisabled = 0;
                                    t.btn_txt = "保存";
                                    t.organization.id = 0;
                                    t.organization.p_name = "";
                                    t.organization.p_code = "0000";
                                    t.organization.p_level = 0;
                                    t.organization.pid = -1;
                                    t.organization.code = "";
                                    t.organization.level = 0;
                                    t.organization.name = "";
                                    t.organization.phone = "";
                                    t.organization.state = 1;
                                } else {
                                    if (treeNode.customer_id == null && treeNode.isP == 1) {
                                        t.select = treeNode;
                                        t.isDisabled = !1;
                                    } else {
                                        t.select = null;
                                        t.isDisabled = 0;
                                    }
                                    t.isSaveDisabled = !1;
                                    if(treeNode.isP == 1) {
                                        t.organization.id = treeNode.id;
                                        t.organization.p_name = treeNode.p_name;
                                        t.organization.p_code = treeNode.p_code;
                                        t.organization.p_level = treeNode.p_level;
                                        t.organization.pid = treeNode.pid;
                                        t.organization.code = treeNode.code;
                                        t.organization.level = treeNode.org_level;
                                        t.organization.name = treeNode.name;
                                        t.organization.phone = treeNode.phone;
                                        t.organization.state = treeNode.state;
                                        t.btn_txt = "修改机构";
                                    } else {
                                        t.organization.id = 0;
                                        t.organization.p_name = treeNode.name;
                                        t.organization.p_code = treeNode.code;
                                        t.organization.p_level = treeNode.org_level;
                                        t.organization.pid = treeNode.id;
                                        t.organization.code = "";
                                        t.organization.level = parseInt(treeNode.org_level)+1;
                                        t.organization.name = "";
                                        t.organization.phone = "";
                                        t.organization.state = 1;
                                        t.btn_txt = "新增机构";
                                    }
                                }
                            }
                        },
                        view: {
                            autoCancelSelected:false,
                            fontCss: function (treeId, treeNode) {
                                return treeNode.customer_id != null && treeNode.isP == 1 ? {color:"red"} : {};
                            },
                            addHoverDom: function (treeId, treeNode) {
                                if (treeNode.customer_id != null && treeNode.isP == 1) {
                                    var aObj = $("#" + treeNode.tId + "_a");
                                    if ($("#diyBtn_space_"+treeNode.id).length>0) return;
                                    var editStr = "<span id='diyBtn_space_" +treeNode.id+ "' >已绑账户</span>";
                                    aObj.append(editStr);
                                }
                            },
                            removeHoverDom:function (treeId, treeNode) {
                                $("#diyBtn_space_" +treeNode.id).unbind().remove();
                            }
                        }
                    };
                    var treeObj = $.fn.zTree.init($("#treeDemo"), setting, i);
                    var nodes = treeObj.getNodes();
                    t.ergodicTree(nodes, treeObj);
                });
            },
            ergodicTree:function (nodes, treeObj) {
                if (nodes.length>0) {
                    for (var i = 0; i<nodes.length; i++) {
                        if (nodes[i].selected == true) {
                            treeObj.selectNode(nodes[i]);
                            treeObj.setting.callback.onClick(null, treeObj.setting.treeId, nodes[i], true);//触发函数
                        }
                        if (nodes[i].children !== undefined) {
                            this.ergodicTree(nodes[i].children, treeObj);
                        }
                    }
                }
            },
            save: function() {
                var t = this;
                t.$validate(true,function () {
                    if(!t.$validatorMethod.invalid) {
                        var index = layer.load(0, {shade:[0.3, '#000000']}); //0代表加载的风格，支持0-2
                        postMsg(root+"/organization/addoredit", t.organization, function(i) {
                            layer.close(index);
                            layer.alert(i.msg, {end:function () {
                                if (i.code == 1) {
                                    if (t.organization.id == 0) {
                                        t.$dispatch("openOrganizationrCommissionSetWin", {organization_id:i.organization.id, organization_name:i.organization.name});
                                    }
                                    t.getTree();
                                }
                            }});
                        });
                    } else {
                        layer.alert(t.showError[(t.showError.length-1)], {end:function () {
                            t.showError = [];
                        }});
                    }
                });
            },
            selectOrg:function () {
                var t = this;
                if (t.select == null) {
                    layer.alert('请选择一个机构');
                } else {
                    var node = t.select;
                    if (node.isSelect == 1) {
                        if (node.customer_id > 0) {
                            layer.alert('同一机构下不能有两个管理员');
                        } else {
                            t.$dispatch("selectOrg", {organization_id:node.id, organization_name:node.name});
                            t.close();
                        }
                    } else {
                        layer.alert('机构选择错误');
                    }
                }
            },
            close: function () {
                var t = this;

                t.select = null;
                t.isDisabled = 0;
                t.isSaveDisabled = 0;
                t.btn_txt = "保存";
                t.organization.id = 0;
                t.organization.p_name = "";
                t.organization.p_code = "0000";
                t.organization.p_level = 0;
                t.organization.pid = -1;
                t.organization.code = "";
                t.organization.level = 0;
                t.organization.name = "";
                t.organization.phone = "";
                t.organization.state = 1;

                t.show = !1;
            }
        }
    })
},  function (t, i) {
    Vue.component("pop-organization-commission-set-component", {
        template:'<div class="pop-panel" v-bind:class="{\'show\':this.show}"><div class="pop-box"><div class="pop-title">{{title}}<a class="win_close_btn" @click="close()"><i class="fa fa-fw fa-close"></i></a></div><div class="pop-content"><div class="row"><div class="col-xs-12"><h2 class="page-header" style="font-size:16px;margin:0px 0 20px 0;padding-bottom:10px;overflow:hidden;">名称：{{organization.name}}<small class="pull-right">上次设置时间: {{last_update_time}}</small></h2></div></div><div class="row"><div class="col-xs-12 table-responsive"><validator name="validatorMethod"><form role="form"><table class="table table-striped"><thead><tr><th>商品名称</th><th>已生效佣金</th><th>未生效佣金</th><th>新佣金设置</th></tr></thead><tbody><tr  v-for="item in organizationCommissionSet"><td>{{item.name}}</td><td><span style="color: #ff470e">{{item.commission_ratio}}%</span></td><td><template v-if="item.is_take_effect==0" >{{item.new_commission_ratio}}% -- <span style="color: #ff470e">生效时间：{{item.take_effect_time}}</span></template><template v-if="item.is_take_effect==1" >--</template></td><td><input type="text" @invalid="commissionInvalid" detect-change="off" detect-blur="off" initial="off" v-validate:commission="[\'required\']" v-bind:value="item.value" v-model="item.value" class="NumDecText" style="text-align:center;width:80px;">%</td></tr></tbody></table><div class="box-footer"><button type="button" class="btn btn-info btn-sm" style="width:120px;float:left;" @click="save()">保存</button><button type="button" class="btn  btn-default btn-sm" style="width:120px;float:left;margin-left:15px;" @click="close()">取消</button><span style="float:left;color:red;margin-left:15px;line-height"30px>注：佣金修改后，下个交易日生效</span></div></form></validator></div></div></div></div><div class="overlay hidden" id="load_comp"><i class="fa fa-refresh fa-spin"></i></div><div class="bg"></div></div>',
        data: function () {
            return {
                show: !1,
                title:'提示窗口',
                showError:null,
                organization:null,
                last_update_time:'--',
                organizationCommissionSet:null
            }
        },
        events: {
            'openOrganizationrCommissionSetWin': function (t) {
                $(".NumDecText").keyup(function(){
                    $(this).val($(this).val().replace(/[^0-9.]/g,''));
                }).bind("paste",function(){  //CTR+V事件处理
                    $(this).val($(this).val().replace(/[^0-9.]/g,''));
                }).css("ime-mode", "disabled"); //CSS设置输入法不可用
                var i = this;
                i.data_init(t);
            },
        },
        methods: {
            commissionInvalid:function () {
                var t = this;
                t.showError.push("佣金设置不能为空");
            },
            data_init: function (t) {
                this.title = t.title, this.organization = t.organization, this.getDate();
            },
            getDate: function () {
                var t = this;
                var index = layer.load(0, {shade:[0.3, '#000000']}); //0代表加载的风格，支持0-2
                postMsg(root+"/organization/getOrganizationCommissionSet", {organization_id:t.organization.id}, function(i) {
                    layer.close(index);
                    t.organizationCommissionSet = i.organizationCommissionSet;
                    t.last_update_time = i.last_update_time;
                    hideLoadById("#load_comp");
                    t.show = !0;
                });
            },
            save: function() {
                var t = this;
                t.$validate(true,function () {
                    if(!t.$validatorMethod.invalid) {
                        var sub_p = new Object();
                        sub_p.organization_id = t.organization.id;
                        var arr = [];
                        for (var i=0; i<t.organizationCommissionSet.length; i++) {
                            var organizationCommissionSet = new Object();
                            organizationCommissionSet.id = t.organizationCommissionSet[i].id;
                            organizationCommissionSet.value = t.organizationCommissionSet[i].value;
                            organizationCommissionSet.game_name = t.organizationCommissionSet[i].name;
                            organizationCommissionSet.game_type = t.organizationCommissionSet[i].type;
                            organizationCommissionSet.open_time = t.organizationCommissionSet[i].open_time;
                            arr.push(organizationCommissionSet);
                        }
                        sub_p.organizationCommissionSet = arr;
                        postMsg(root+"/organization/addOrganizationCommissionSet", sub_p, function(i) {
                            layer.alert(i.msg, {end:function () {
                                if (i.code == 0) {
                                    t.show = !1;
                                }
                            }});
                        });
                    } else {
                        layer.alert(t.showError[(t.showError.length-1)], {end:function () {
                            t.showError = [];
                        }});
                    }
                });
            },
            close: function () {
                var t = this;
                t.show = !1;
            }
        }
    })
},  function (t, i) {
    Vue.component("pop-risk-control-rate-component", {
        template:'<div class="pop-panel" v-bind:class="{\'show\':this.show}"><div class="pop-box"><div class="pop-title">{{title}}<a class="win_close_btn" @click="close()"><i class="fa fa-fw fa-close"></i></a></div><div class="pop-content"><validator name="validatorMethod"><form role="form"><div class="box-body"><div class="form-group"><label for="title">风险控制率（%）</label><input type="text" id="name" v-model="organization.risk_control_rate" @invalid="riskControlRateInvalid" detect-change="off" detect-blur="off" initial="off" v-validate:risk_control_rate="[\'required\']" v-bind:value="organization.risk_control_rate" class="form-control NumDecText"></div></div><div class="box-footer"><button type="button" class="btn btn-info btn-sm" style="width:120px;float:left;" @click="save()">保存</button><button type="button" class="btn  btn-default btn-sm" style="width:120px;float:left;margin-left:15px;" @click="close()">取消</button></div></form></validator></div></div><div class="bg"></div></div>',
        data: function () {
            return {
                show: !1,
                title:'提示窗口',
                showError:null,
                organization: {
                    id:0,
                    risk_control_rate:0
                }
            }
        },
        events: {
            openRiskControlRateWin: function (t) {
                $(".NumDecText").keyup(function(){
                    $(this).val($(this).val().replace(/[^0-9.]/g,''));
                }).bind("paste",function(){  //CTR+V事件处理
                    $(this).val($(this).val().replace(/[^0-9.]/g,''));
                }).css("ime-mode", "disabled"); //CSS设置输入法不可用

                var i = this;
                i.data_init(t);
            }
        },
        methods: {
            data_init: function (t) {
                this.title = t.title, this.organization = t.organization, this.showError = [], this.show = !0;
            },
            riskControlRateInvalid: function () {
                var t = this;
                t.showError.push("风险控制率不能为空");
            },
            save: function() {
                var t = this;
                t.$validate(true,function () {
                    if(!t.$validatorMethod.invalid) {
                        var index = layer.load(0, {shade:[0.3, '#000000']}); //0代表加载的风格，支持0-2
                        postMsg(root+"/organization/setData", t.organization, function(i) {
                            layer.close(index);
                            layer.alert(i.msg);
                            if (i.code == 1) {
                                t.show = !1;
                                t.$dispatch("refreshCustomerField", {customer_id:t.organization.customer_id, key:"risk_control_rate", value:t.organization.risk_control_rate});
                            }
                        });
                    } else {
                        layer.alert(t.showError[(t.showError.length-1)], {end:function () {
                            t.showError = [];
                        }});
                    }
                });
            },
            close: function () {
                var t = this;
                t.show = !1;
            }
        }
    })
}]);